Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: rtc: rpi_pico: Add support for the Raspberry Pi Pico RTC #64939

Merged
merged 3 commits into from
Mar 6, 2024

Conversation

ajf58
Copy link
Contributor

@ajf58 ajf58 commented Nov 7, 2023

This adds the minimal get_time/set_time support for the RP2040 SOC and enables support by default on the Pico boards. This doesn't support configuring the clock source or alarm interrupts yet.

@ajf58 ajf58 requested review from nashif and yonsch as code owners November 7, 2023 20:59
@zephyrbot zephyrbot added area: Devicetree Binding PR modifies or adds a Device Tree binding area: RTC Real Time Clock platform: Raspberry Pi Pico Raspberry Pi Pico (RPi Pico) labels Nov 7, 2023
Copy link

github-actions bot commented Nov 7, 2023

Hello @ajf58, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

Copy link
Collaborator

@bjarki-andreasen bjarki-andreasen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it looks good, I have requested minor changes, and will request you run the RTC test suite if you haven't already to validate the driver :) (and fix the compliance issues naturally)

drivers/rtc/rtc_rpi_pico.c Outdated Show resolved Hide resolved
drivers/rtc/rtc_rpi_pico.c Outdated Show resolved Hide resolved
drivers/rtc/rtc_rpi_pico.c Outdated Show resolved Hide resolved
@ajf58 ajf58 force-pushed the pico_rtc branch 2 times, most recently from df58b12 to 2997249 Compare November 8, 2023 11:38
@yonsch
Copy link
Contributor

yonsch commented Nov 8, 2023

This should be merged only after #62186 has been merged, so that it uses the new clock definitions

@bjarki-andreasen bjarki-andreasen added the DNM This PR should not be merged (Do Not Merge) label Nov 8, 2023
@bjarki-andreasen
Copy link
Collaborator

This should be merged only after #62186 has been merged, so that it uses the new clock definitions

Added the DNM label :)

@ajf58 ajf58 force-pushed the pico_rtc branch 2 times, most recently from 039e4b2 to 905e92a Compare November 16, 2023 22:37
@raveious
Copy link
Contributor

Looks like #62186 has merged, can we keep this going?

@ajf58
Copy link
Contributor Author

ajf58 commented Dec 22, 2023

Looks like #62186 has merged, can we keep this going?

Now that I've finished work for the year, yes. Locally I've rebased onto the HEAD of main to bring in the new clock controller work, and I think I've made the relevant other changes to my driver. I'll test those changes locally before pushing anything to my branch.

drivers/rtc/rtc_rpi_pico.c Show resolved Hide resolved
drivers/rtc/rtc_rpi_pico.c Show resolved Hide resolved
@yonsch yonsch removed the DNM This PR should not be merged (Do Not Merge) label Dec 24, 2023
@ajf58
Copy link
Contributor Author

ajf58 commented Dec 24, 2023

I think this is ready for another round of review feedback. This driver now includes both the time and the alarm API.

Testing

I've run this with the RTC API test suite, and got these results:

*** Booting Zephyr OS build zephyr-v3.5.0-3468-g897f8e5b481e ***
Running TESTSUITE rtc_api
===================================================================
START - test_alarm
I: Setting alarm
I: Setting alarm
I: Setting alarm
 PASS - test_alarm in 26.006 seconds
===================================================================
START - test_alarm_callback
I: Setting alarm
I: Setting alarm
 PASS - test_alarm_callback in 26.004 seconds
===================================================================
START - test_set_get_time
 PASS - test_set_get_time in 0.001 seconds
===================================================================
START - test_time_counting
 PASS - test_time_counting in 9.003 seconds
===================================================================
START - test_y2k

    Assertion failed at WEST_TOPDIR/zpico/tests/drivers/rtc/rtc_api/src/test_y2k.c:59: rtc_api_test_y2k: (rtm[Y2K].tm_sec not equal to SECONDS_AFTER)
wrong second: 2
 FAIL - test_y2k in 2.015 seconds
===================================================================
TESTSUITE rtc_api failed.

------ TESTSUITE SUMMARY START ------

SUITE FAIL -  80.00% [rtc_api]: pass = 4, fail = 1, skip = 0, total = 5 duration = 63.029 seconds
 - PASS - [rtc_api.test_alarm] duration = 26.006 seconds
 - PASS - [rtc_api.test_alarm_callback] duration = 26.004 seconds
 - PASS - [rtc_api.test_set_get_time] duration = 0.001 seconds
 - PASS - [rtc_api.test_time_counting] duration = 9.003 seconds
 - FAIL - [rtc_api.test_y2k] duration = 2.015 seconds

------ TESTSUITE SUMMARY END ------

===================================================================
PROJECT EXECUTION FAILED

the test_y2k failure is something I'm not sure about; I'm wondering if this test needs the same use of RTC_TEST_GET_SET_TIME_TOL as found elsewhere and I'd welcome some thoughts.

@nordicjm nordicjm requested a review from yonsch January 2, 2024 12:20
@bjarki-andreasen
Copy link
Collaborator

Nice, the rtc_utils are great :) I would like an extra test suite in tests/drivers/rtc/rtc_utils to validate the rtc_utils_validate_tm function on its own as well :) and I think the function rtc_utils_validate_tm should be named rtc_utils_validate_rtc_time since tm could refer to the struct tm which does allow -1 values :)

@ajf58
Copy link
Contributor Author

ajf58 commented Feb 29, 2024

I would like an extra test suite in tests/drivers/rtc/rtc_utils to validate the rtc_utils_validate_tm function on its own as well :) and I think the function rtc_utils_validate_tm should be named rtc_utils_validate_rtc_time since tm could refer to the struct tm which does allow -1 values :)

I've done this as requested.

Copy link
Member

@soburi soburi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes are LGTM.
Please squash and cleanup commits.

RTC drivers should validate the `struct rtc_time`'s contents against the
provided `mask`. Promote this common code to a new rtc_utils file and
modify existing drivers to use this functionality. Extend the test
coverage to include verifying this behaviour.

This is groundwork ahead of adding support for the RP2040's (as used in
the Raspberry Pi Pico) RTC and alarm.

Signed-off-by: Andrew Featherstone <[email protected]>
@ajf58
Copy link
Contributor Author

ajf58 commented Mar 4, 2024

I did a quick correction and rebase to address a code-style issue. The CI pipeline failures are due to the runners disappearing:

The self-hosted runner: zephyr-runner-linux-x64-4xlarge-deployment-g2tcl-r7ttn lost communication with the server.

which I don't think is down to me adding a blank line in a source file ;-).

How do we proceed? Does this require someone with higher privileges to re-run the pipeline, for example?

drivers/rtc/rtc_rpi_pico.c Outdated Show resolved Hide resolved
ajf58 added 2 commits March 5, 2024 20:18
This adds the minimal get_time/set_time support for the rp2040 and
enables support by default on the Pico boards. This doesn't support
configuring the clock source or alarm interrupts yet.

Signed-off-by: Andrew Featherstone <[email protected]>
This adds support for the alarm functionality of the RPi Pico RTC.

Signed-off-by: Andrew Featherstone <[email protected]>
@ajf58
Copy link
Contributor Author

ajf58 commented Mar 5, 2024

Can we get this over the line please?

@fabiobaltieri fabiobaltieri merged commit 1c50ba4 into zephyrproject-rtos:main Mar 6, 2024
21 checks passed
Copy link

github-actions bot commented Mar 6, 2024

Hi @ajf58!
Congratulations on getting your very first Zephyr pull request merged 🎉🥳. This is a fantastic achievement, and we're thrilled to have you as part of our community!

To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge.

Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁

nandojve added a commit to nandojve/zephyr that referenced this pull request Nov 15, 2024
The zephyrproject-rtos#64939 introduced a few convenience function like
rtc_utils_validate_rtc_time. However the PR did not replace all
occurrences which result on a build error. This add the missing
header include to remove a building warning and replace the old
function by the new one.

Fixes zephyrproject-rtos#81454

Signed-off-by: Gerson Fernando Budke <[email protected]>
mmahadevan108 pushed a commit that referenced this pull request Nov 15, 2024
The #64939 introduced a few convenience function like
rtc_utils_validate_rtc_time. However the PR did not replace all
occurrences which result on a build error. This add the missing
header include to remove a building warning and replace the old
function by the new one.

Fixes #81454

Signed-off-by: Gerson Fernando Budke <[email protected]>
JA-NXP pushed a commit to nxp-upstream/zephyr that referenced this pull request Nov 19, 2024
The zephyrproject-rtos#64939 introduced a few convenience function like
rtc_utils_validate_rtc_time. However the PR did not replace all
occurrences which result on a build error. This add the missing
header include to remove a building warning and replace the old
function by the new one.

Fixes zephyrproject-rtos#81454

Signed-off-by: Gerson Fernando Budke <[email protected]>
zephyrbot pushed a commit that referenced this pull request Nov 23, 2024
The #64939 introduced a few convenience function like
rtc_utils_validate_rtc_time. However the PR did not replace all
occurrences which result on a build error. This add the missing
header include to remove a building warning and replace the old
function by the new one.

Fixes #81454

Signed-off-by: Gerson Fernando Budke <[email protected]>
(cherry picked from commit d71d4c0)
nashif pushed a commit that referenced this pull request Nov 29, 2024
The #64939 introduced a few convenience function like
rtc_utils_validate_rtc_time. However the PR did not replace all
occurrences which result on a build error. This add the missing
header include to remove a building warning and replace the old
function by the new one.

Fixes #81454

Signed-off-by: Gerson Fernando Budke <[email protected]>
(cherry picked from commit d71d4c0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree Binding PR modifies or adds a Device Tree binding area: RTC Real Time Clock platform: Microchip SAM Microchip SAM Platform (formerly Atmel SAM) platform: Raspberry Pi Pico Raspberry Pi Pico (RPi Pico)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants